{
GtkComboBoxPrivate *priv = combo_box->priv;
gint active_item;
- GtkAllocation border_allocation;
- GtkAllocation content_allocation;
GtkWidget *active;
update_menu_sensitivity (combo_box, priv->popup_widget);
if (priv->wrap_width == 0)
{
- gint width, min_width, nat_width;
+ int width, height, min_width, nat_width;
- gtk_widget_get_content_allocation (GTK_WIDGET (combo_box), &content_allocation);
- width = content_allocation.width;
+ gtk_widget_get_content_size (GTK_WIDGET (combo_box), &width, &height);
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
&min_width, &nat_width, NULL, NULL);
if (priv->wrap_width > 0 || priv->cell_view == NULL)
{
- gtk_widget_get_border_allocation (GTK_WIDGET (combo_box), &border_allocation);
- gtk_widget_get_content_allocation (GTK_WIDGET (combo_box), &content_allocation);
-
g_object_set (priv->popup_widget,
"anchor-hints", (GDK_ANCHOR_FLIP_Y |
GDK_ANCHOR_SLIDE |
GDK_ANCHOR_RESIZE),
- "rect-anchor-dx", border_allocation.x - content_allocation.x,
+ "rect-anchor-dx", 0,
NULL);
gtk_menu_popup_at_widget (GTK_MENU (priv->popup_widget),
{
GtkEntryPrivate *priv = entry->priv;
- gtk_widget_get_content_allocation (GTK_WIDGET (entry), allocation);
+ gtk_widget_get_own_allocation (GTK_WIDGET (entry), allocation);
allocation->x = priv->text_x;
allocation->width = priv->text_width;
}
gtk_entry_move_adjustments (GtkEntry *entry)
{
GtkWidget *widget = GTK_WIDGET (entry);
- GtkAllocation allocation;
GtkAdjustment *adjustment;
PangoContext *context;
PangoFontMetrics *metrics;
if (!adjustment)
return;
- gtk_widget_get_content_allocation (GTK_WIDGET (entry), &allocation);
-
- /* Cursor/char position, layout offset, border width, and widget allocation */
+ /* Cursor/char position, layout offset and border width*/
gtk_entry_get_cursor_locations (entry, &x, NULL);
get_layout_position (entry, &layout_x, NULL);
- x += allocation.x + layout_x;
+ x += layout_x;
/* Approximate width of a char, so user can see what is ahead/behind */
context = gtk_widget_get_pango_context (widget);
int ypos)
{
GtkPanedPrivate *priv = paned->priv;
- GtkAllocation allocation;
+ int width, height;
gint pos;
gint handle_size;
gint size;
- gtk_widget_get_content_allocation (GTK_WIDGET (paned), &allocation);
+ gtk_widget_get_content_size (GTK_WIDGET (paned), &width, &height);
+
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
pos = xpos;
else
NULL, &handle_size,
NULL, NULL);
- size = allocation.width - pos - handle_size;
+ size = width - pos - handle_size;
}
else
{
GtkAllocation slider_alloc, trough_alloc;
gtk_widget_get_outer_allocation (priv->slider_widget, &slider_alloc);
- gtk_widget_get_content_allocation (priv->trough_widget, &trough_alloc);
+ gtk_widget_get_outer_allocation (priv->trough_widget, &trough_alloc);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
GtkWidget *widget = GTK_WIDGET (scale);
GtkRange *range = GTK_RANGE (widget);
GtkWidget *slider_widget;
- GtkAllocation range_alloc, slider_alloc, value_alloc;
+ GtkAllocation slider_alloc, value_alloc;
+ int range_width, range_height;
- gtk_widget_get_content_allocation (widget, &range_alloc);
+ gtk_widget_get_content_size (widget, &range_width, &range_height);
slider_widget = gtk_range_get_slider_widget (range);
gtk_widget_get_border_allocation (slider_widget, &slider_alloc);
{
case GTK_POS_LEFT:
value_alloc.x = 0;
- value_alloc.y = (range_alloc.height - value_alloc.height) / 2;
+ value_alloc.y = (range_height - value_alloc.height) / 2;
break;
case GTK_POS_RIGHT:
- value_alloc.x = range_alloc.width - value_alloc.width;
- value_alloc.y = (range_alloc.height - value_alloc.height) / 2;
+ value_alloc.x = range_width - value_alloc.width;
+ value_alloc.y = (range_height - value_alloc.height) / 2;
break;
case GTK_POS_TOP:
case GTK_POS_BOTTOM:
value_alloc.x = slider_alloc.x + (slider_alloc.width - value_alloc.width) / 2;
- value_alloc.y = range_alloc.height - value_alloc.height;
+ value_alloc.y = range_height - value_alloc.height;
break;
default:
break;
case GTK_POS_RIGHT:
- value_alloc.x = range_alloc.width - value_alloc.width;
+ value_alloc.x = range_width - value_alloc.width;
value_alloc.y = (slider_alloc.y + (slider_alloc.height / 2)) - value_alloc.height / 2;
break;
case GTK_POS_TOP:
- value_alloc.x = (range_alloc.width - value_alloc.width) / 2;
+ value_alloc.x = (range_width - value_alloc.width) / 2;
value_alloc.y = 0;
break;
case GTK_POS_BOTTOM:
- value_alloc.x = (range_alloc.width - value_alloc.width) / 2;
- value_alloc.y = range_alloc.height - value_alloc.height;
+ value_alloc.x = (range_width - value_alloc.width) / 2;
+ value_alloc.y = range_height - value_alloc.height;
break;
default:
return;
}
- gtk_widget_get_content_allocation (priv->value_widget, &value_alloc);
+ gtk_widget_get_outer_allocation (priv->value_widget, &value_alloc);
*x = value_alloc.x;
*y = value_alloc.y;
GtkScrolledWindowPrivate *priv;
gint sb_width;
gint sb_height;
- GtkAllocation content_allocation;
+ int width, height;
g_return_if_fail (widget != NULL);
g_return_if_fail (allocation != NULL);
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
&sb_height, NULL, NULL, NULL);
- gtk_widget_get_content_allocation (widget, &content_allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
- allocation->x = content_allocation.x;
- allocation->y = content_allocation.y;
- allocation->width = content_allocation.width;
- allocation->height = content_allocation.height;
+ allocation->x = 0;
+ allocation->y = 0;
+ allocation->width = width;
+ allocation->height = height;
/* Subtract some things from our available allocation size */
if (priv->vscrollbar_visible && !priv->use_indicators)
priv->window_placement == GTK_CORNER_BOTTOM_LEFT)))
allocation->x += sb_width;
- allocation->width = MAX (1, content_allocation.width - sb_width);
+ allocation->width = MAX (1, width - sb_width);
}
if (priv->hscrollbar_visible && !priv->use_indicators)
priv->window_placement == GTK_CORNER_BOTTOM_RIGHT)
allocation->y += (sb_height);
- allocation->height = MAX (1, content_allocation.height - sb_height);
+ allocation->height = MAX (1, height - sb_height);
}
}
g_source_set_name_by_id (priv->idle_id, "[gtk+] slide_idle_handler");
}
- gtk_widget_get_content_allocation (widget, &content_allocation);
+ gtk_widget_get_own_allocation (widget, &content_allocation);
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL);
{
if (x_out && y_out)
{
- GtkAllocation content_alloc;
- gtk_widget_get_content_allocation (child, &content_alloc);
+ GtkAllocation own_alloc;
+ gtk_widget_get_own_allocation (child, &own_alloc);
- *x_out = x - content_alloc.x;
- *y_out = y - content_alloc.y;
+ *x_out = own_alloc.x + (x - allocation.x);
+ *y_out = own_alloc.y + (y - allocation.y);
}
return child;
return widget_a;
}
+static void
+gtk_widget_get_origin_relative_to_parent (GtkWidget *widget,
+ int *origin_x,
+ int *origin_y)
+{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ GtkBorder margin, border, padding;
+ GtkCssStyle *style;
+
+ style = gtk_css_node_get_style (priv->cssnode);
+ get_box_margin (style, &margin);
+ get_box_border (style, &border);
+ get_box_padding (style, &padding);
+
+ /* allocation is relative to the parent's origin */
+ *origin_x = priv->allocation.x;
+ *origin_y = priv->allocation.y;
+
+ /* ... but points to the upper left, excluding widget margins
+ * but including all the css properties */
+ *origin_x += margin.left + border.left + padding.left;
+ *origin_y += margin.top + border.top + padding.top;
+}
+
/**
* gtk_widget_translate_coordinates:
* @src_widget: a #GtkWidget
parent = src_widget;
while (parent != ancestor)
{
- GtkAllocation content_alloc;
+ int origin_x, origin_y;
- gtk_widget_get_content_allocation (parent, &content_alloc);
+ gtk_widget_get_origin_relative_to_parent (parent, &origin_x, &origin_y);
- src_x += content_alloc.x;
- src_y += content_alloc.y;
+ src_x += origin_x;
+ src_y += origin_y;
parent = _gtk_widget_get_parent (parent);
}
parent = dest_widget;
while (parent != ancestor)
{
- GtkAllocation content_alloc;
+ int origin_x, origin_y;
- gtk_widget_get_content_allocation (parent, &content_alloc);
+ gtk_widget_get_origin_relative_to_parent (parent, &origin_x, &origin_y);
- src_x -= content_alloc.x;
- src_y -= content_alloc.y;
+ src_x -= origin_x;
+ src_y -= origin_y;
parent = _gtk_widget_get_parent (parent);
}
gtk_widget_get_content_size (GtkWidget *widget,
int *width,
int *height)
-{
- GtkAllocation alloc;
-
- gtk_widget_get_content_allocation (widget, &alloc);
-
- *width = alloc.width;
- *height = alloc.height;
-}
-
-void
-gtk_widget_get_content_allocation (GtkWidget *widget,
- GtkAllocation *allocation)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkBorder margin, border, padding;
get_box_border (style, &border);
get_box_padding (style, &padding);
- *allocation = priv->allocation;
+ *width = priv->allocation.width;
+ *height = priv->allocation.height;
- allocation->x += margin.left + border.left + padding.left;
- allocation->y += margin.top + border.top + padding.top;
- allocation->width -= margin.left + border.left + padding.left +
- margin.right + border.right + padding.right;
- allocation->height -= margin.top + border.top + padding.top +
- margin.bottom + border.bottom + padding.bottom;
+ *width -= margin.left + border.left + padding.left +
+ margin.right + border.right + padding.right;
+ *height -= margin.top + border.top + padding.top +
+ margin.bottom + border.bottom + padding.bottom;
}
void
gboolean gtk_widget_focus_move (GtkWidget *widget,
GtkDirectionType direction,
GPtrArray *focus_order);
-void gtk_widget_get_content_allocation (GtkWidget *widget,
- GtkAllocation *allocation);
void gtk_widget_get_border_allocation (GtkWidget *widget,
GtkAllocation *allocation);
void gtk_widget_get_outer_allocation (GtkWidget *widget,